//
//  YFUserSeriesViewModel.m
//  SquashSpark
//
//  Created by Coollang on 2017/11/17.
//  Copyright © 2017年 Coollang-YF. All rights reserved.
//

#import "YFUserSeriesViewModel.h"
#import "YFUserDefaults.h"

@interface YFUserSeriesViewModel()

/** 身高 */
@property (nonatomic, strong) NSArray <NSString *> *heights;
/** 体重 */
@property (nonatomic, strong) NSArray <NSString *> *weights;
/** 身高Inch 和ft 制 */
@property (nonatomic, strong) NSDictionary <NSString *,NSArray *> *inchHeights;

/** Training目标训练时间  key:有Day week month*/
@property (nonatomic, strong) NSDictionary <NSString *,NSArray *> *trainingHours;


@end

@implementation YFUserSeriesViewModel
+ (instancetype)shareInstance {
    static YFUserSeriesViewModel *_instance;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        _instance = [[YFUserSeriesViewModel alloc] init];
    });
    return _instance;
}

- (NSArray<NSString *> *)heights {
    if (_heights == nil) {
        NSMutableArray *arrM = [NSMutableArray array];
        for (NSInteger i = 100; i < 230; i++) {
            [arrM addObject:[NSString stringWithFormat:@"%zdcm", i]];
        }
        _heights = arrM.copy;
    }
    return _heights;
}

- (NSArray<NSString *> *)weights {
    
    if ([YFUserDefaults generalMetricSystemUnit]) {
        NSMutableArray *arrM = [NSMutableArray array];
        for (NSInteger i = 20; i <= 300; i++) {
            [arrM addObject:[NSString stringWithFormat:@"%zdkg", i]];
        }
        _weights = arrM.copy;
        
    }else {
        NSMutableArray *arrM = [NSMutableArray array];
        for (NSInteger i = 40; i <= 660; i++) {
            [arrM addObject:[NSString stringWithFormat:@"%zdlbs", i]];
        }
        _weights = arrM.copy;
    }
    return _weights;
}

- (NSDictionary<NSString *, NSArray*> *)inchHeights {
    if (_inchHeights == nil) {
        NSMutableArray *inchArrM = [NSMutableArray array];
        for (NSInteger i = 0; i < 100; i++) {
            [inchArrM addObject:[NSString stringWithFormat:@"%.1f in",(i/10.0)]];
        }
        NSMutableDictionary *dictM = [NSMutableDictionary dictionary];
        for (NSInteger i = 1; i <= 8; i++) {
            [dictM setObject:inchArrM.copy forKey:[NSString stringWithFormat:@"%zd ft",i]];
        }
        _inchHeights = dictM.copy;
    }
    return _inchHeights;
}

- (NSDictionary<NSString *,NSArray *> *)trainingHours {
    if (_trainingHours == nil) {
        NSMutableArray *hoursM = [NSMutableArray array];
        for (int i = 1; i < 10; i++) {
            [hoursM addObject:[NSString stringWithFormat:@"%zdhour",i]];
        }
        _trainingHours = [NSDictionary dictionaryWithObjects:@[hoursM.copy,hoursM.copy,hoursM.copy] forKeys:@[@"per Day",@"per Week",@"per month"]];
    }
    return _trainingHours;
}

@end
